(function(){

    function init(){
    document.getElementById('btn_register').addEventListener("click",()=>{
        let userName= document.getElementById("userName").value;
        let password= document.getElementById("password").value;
        let rePassword= document.getElementById("rePassword").value;
        let province=document.getElementById("province").value;
        let city=document.getElementById("city").value;
        let sexList= document.getElementsByName("sex");
        let hobbyArray=[];
        let sexValue;
       Array.from(sexList).forEach((item)=>{
           if(item.checked==true){
               sexValue=item.value;
           }
       })
        let hobbyList=document.getElementsByName("fav");
        Array.from(hobbyList).forEach((item)=>{
            if(item.checked==true){
                hobbyArray.push(item.value);
            }

        })
       let regx=/^[a-zA-Z]{5,8}$/;
       // 判断userName 是否是字母
      if(regx.test(userName)==false){
        document.getElementById("userNameMessage").innerHTML="用户名不符合要求";
      }else if(regx.test(userName)==true){
        document.getElementById("userNameMessage").innerHTML="";
      }
      // 判断密码和重复密码是否一致
      if(password!=rePassword){
        document.getElementById("rePasswordMessage").innerHTML="密码不一致"; 
      }else{
        document.getElementById("rePasswordMessage").innerHTML=""; 
      }
    },false);
    
}


    window.addEventListener("load",init,false);
})();